import request from '@/utils/requestUtil'

// 添加商品评价
export function createComment(commentParam) {
  return request({
    method: 'POST',
    url: '/comment/create',
    data: commentParam
  })
}

// 分页查询商品评价
export function listComments(productId, pageSize, pageNum) {
  return request({
    method: 'GET',
    url: '/comment/list',
    params: {
      productId,
      pageSize,
      pageNum
    }
  })
}

// 分页查询我的评价
export function listMyComments(pageSize, pageNum) {
  return request({
    method: 'GET',
    url: '/comment/myComments',
    params: {
      pageSize,
      pageNum
    }
  })
}

// 获取评价详情
export function getCommentDetail(id) {
  return request({
    method: 'GET',
    url: `/comment/detail/${id}`
  })
}

// 根据ID查询商品评价
export function getComment(id) {
  return request({
    method: 'GET',
    url: `/comment/${id}`
  })
}

// 删除评价
export function deleteComments(ids) {
  return request({
    method: 'POST',
    url: '/comment/delete',
    params: {
      ids
    }
  })
}

// 添加评价回复
export function createReply(commentId, content) {
  return request({
    method: 'POST',
    url: '/comment/reply/create',
    params: {
      commentId,
      content
    }
  })
}

// 获取商品的评价列表
export function getProductComments(productId, pageSize, pageNum, star) {
  return request({
    method: 'GET',
    url: '/comment/productComments',
    params: {
      productId,
      pageSize,
      pageNum,
      star
    }
  })
}

// 获取商品评价统计信息
export function getCommentStatistics(productId) {
  return request({
    method: 'GET',
    url: '/comment/statistics',
    params: {
      productId
    }
  })
} 